package com.ermax.aircond.util.service;

import org.springframework.stereotype.Service;

@Service("mimeTypeService")
public class MimeTypeService {

	public String getImageMimeType(String filename) {
		String mime = "image/unknown";
		int extDot = filename.lastIndexOf('.');
		if (extDot > 0) {
			String extension = filename.substring(extDot + 1);
			if ("bmp".equals(extension)) {
				mime = "image/bmp";
			} else if ("jpg".equals(extension)) {
				mime = "image/jpeg";
			} else if ("gif".equals(extension)) {
				mime = "image/gif";
			} else if ("png".equals(extension)) {
				mime = "image/png";
			} else {
				mime = "image/unknown";
			}
		}
		return mime;
	}
}
